package com.zyddd.common;

import lombok.Data;

//添加get方法，有get方法的属性才会转换称JSON
@Data
public class R<T> {
    private Boolean ok;
    private String msg;
    private T data;

    public static <T> R<T> success(String msg) {
        R<T> r = new R<>();
        r.ok = true;
        r.msg = msg;
        return r;
    }

    public static <T> R<T> success(String msg, T data) {
        R<T> r = new R<>();
        r.ok = true;
        r.msg = msg;
        r.data = data;
        return r;
    }

    public static <T> R<T> error(String msg) {
        R<T> r = new R<>();
        r.ok = false;
        r.msg = msg;
        return r;
    }
}
